import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:wowhy/models/admin_user_info.dart';

class AdminUserEditState implements Cloneable<AdminUserEditState> {
  GlobalKey<FormBuilderState> formKey = GlobalKey<FormBuilderState>();
  String mode;
  String id;

  AdminUserInfo rawModel;
  AdminUserInfo formModel;

  AdminUserEditState({
    this.formKey,
    this.mode = 'add',
    this.id,
    this.rawModel,
    this.formModel,
  });

  @override
  AdminUserEditState clone() {
    return AdminUserEditState(
      mode: mode,
      id: id,
      formKey: formKey,
      rawModel: rawModel,
      formModel: formModel,
    );
  }
}

AdminUserEditState initState(Map<String, dynamic> args) {
  String id = args != null ? args['id'] : null;
  String mode = id == null ? 'add' : (args['mode'] ?? 'edit');

  return AdminUserEditState(
    formKey: GlobalKey<FormBuilderState>(),
    mode: mode,
    id: id,
    rawModel: AdminUserInfo(),
    formModel: AdminUserInfo(),
  );
}
